raw_printers
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Thu, 15 Aug 2019 14:15:39 +0000 (15:15 +0100)
committerDmitry Shachnev <mitya57@debian.org>
Thu, 15 Aug 2019 14:15:39 +0000 (15:15 +0100)
Gbp-Pq: Name raw_printers.diff

src/plugins/printsupport/cups/qcupsprintengine.cpp
src/plugins/printsupport/cups/qppdprintdevice.cpp
src/printsupport/dialogs/qpagesetupdialog_unix.cpp

index 6c29a99705c9d0c025951bb2d66e4cc17fb1f00b..c393229b1f1436ccca14b9e400bb810fe77dc8b0 100644 (file)
@@ -104,7 +104,11 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
         break;
     case PPK_QPageLayout: {
         QPageLayout pageLayout = value.value<QPageLayout>();
-        if (pageLayout.isValid() && (d->m_printDevice.isValidPageLayout(pageLayout, d->resolution) || d->m_printDevice.supportsCustomPageSizes())) {
+        if (pageLayout.isValid() && (d->m_printDevice.isValidPageLayout(pageLayout, d->resolution)
+                                     || d->m_printDevice.supportsCustomPageSizes()
+                                     || d->m_printDevice.supportedPageSizes().isEmpty())) {
+            // supportedPageSizes().isEmpty() because QPageSetupWidget::initPageSizes says
+            // "If no available printer page sizes, populate with all page sizes"
             d->m_pageLayout = pageLayout;
             d->setPageSize(pageLayout.pageSize());
         }
index f0a8105d211dd6ce7d3f7e2952358af0a210b41d..53d3b5a49f90c8fbba76098feb8783d532449b5a 100644 (file)
@@ -71,7 +71,7 @@ QPpdPrintDevice::QPpdPrintDevice(const QString &id)
             m_cupsInstance = parts.at(1).toUtf8();
         loadPrinter();
 
-        if (m_cupsDest && m_ppd) {
+        if (m_cupsDest) {
             m_name = printerOption("printer-info");
             m_location = printerOption("printer-location");
             m_makeAndModel = printerOption("printer-make-and-model");
@@ -87,10 +87,6 @@ QPpdPrintDevice::QPpdPrintDevice(const QString &id)
             // Cups ppd_file_t variable_sizes custom_min custom_max
             // PPD MaxMediaWidth MaxMediaHeight
             m_supportsCustomPageSizes = type & CUPS_PRINTER_VARIABLE;
-            m_minimumPhysicalPageSize = QSize(m_ppd->custom_min[0], m_ppd->custom_min[1]);
-            m_maximumPhysicalPageSize = QSize(m_ppd->custom_max[0], m_ppd->custom_max[1]);
-            m_customMargins = QMarginsF(m_ppd->custom_margins[0], m_ppd->custom_margins[3],
-                                        m_ppd->custom_margins[2], m_ppd->custom_margins[1]);
         }
     }
 }
@@ -107,7 +103,7 @@ QPpdPrintDevice::~QPpdPrintDevice()
 
 bool QPpdPrintDevice::isValid() const
 {
-    return m_cupsDest && m_ppd;
+    return m_cupsDest;
 }
 
 bool QPpdPrintDevice::isDefault() const
@@ -152,8 +148,8 @@ void QPpdPrintDevice::loadPageSizes() const
                 }
             }
         }
-        m_havePageSizes = true;
     }
+    m_havePageSizes = true;
 }
 
 QPageSize QPpdPrintDevice::defaultPageSize() const
@@ -505,10 +501,11 @@ void QPpdPrintDevice::loadPrinter()
             ppdMarkDefaults(m_ppd);
             cupsMarkOptions(m_ppd, m_cupsDest->num_options, m_cupsDest->options);
             ppdLocalize(m_ppd);
-        } else {
-            cupsFreeDests(1, m_cupsDest);
-            m_cupsDest = 0;
-            m_ppd = 0;
+
+            m_minimumPhysicalPageSize = QSize(m_ppd->custom_min[0], m_ppd->custom_min[1]);
+            m_maximumPhysicalPageSize = QSize(m_ppd->custom_max[0], m_ppd->custom_max[1]);
+            m_customMargins = QMarginsF(m_ppd->custom_margins[0], m_ppd->custom_margins[3],
+                                        m_ppd->custom_margins[2], m_ppd->custom_margins[1]);
         }
     }
 }
index 7e32f9aa57a1720ebcf1deedf2118c34ea17b125..3648d3fefe7f838ecf20c4f950ecc6a436158d3d 100644 (file)
@@ -415,6 +415,12 @@ void QPageSetupWidget::setPrinter(QPrinter *printer, QPrintDevice *printDevice,
     initPageSizes();
     updateWidget();
     updateSavedValues();
+
+    if (m_ui.pageSizeCombo->currentIndex() == -1) {
+        // This can happen in raw printers that since they don't have a default
+        // page size none will get selected so just default to the first size (A4)
+        m_ui.pageSizeCombo->setCurrentIndex(0);
+    }
 }
 
 // Update the widget with the current settings